<%= render :partial => 'spree/shared/error_messages', :locals => { :target => @subscription } %>

<%= form_for @subscription, url: recurring_plan_subscriptions_url(@plan) do |f| %>
  <%= image_tag 'credit_cards/credit_card.gif', :id => 'credit-card-image' %>

  <div id="plan_<%= @plan.id %>_subscribe">
    <p class="field" data-hook="card_number">
      <%= label_tag "card_number", Spree.t(:card_number) %><span class="required">*</span><br />
      <% options_hash = Rails.env.production? ? {:autocomplete => 'off'} : {} %>
      <%= text_field_tag "card_number", '', options_hash.merge(:id => 'card_number', :class => 'required cardNumber', :size => 19, :maxlength => 19, :autocomplete => "off") %>
      &nbsp;
      <span id="card_type" style="display:none;">
        ( <span id="looks_like" ><%= Spree.t(:card_type_is) %> <span id="type"></span></span>
          <span id="unrecognized"><%= Spree.t(:unrecognized_card_type) %></span>
        )
      </span>
    </p>
    <p class="field" data-hook="card_expiration">
      <%= label_tag "card_expiry", Spree.t(:expiration) %><span class="required">*</span><br />
      <%= text_field_tag "card_expiry", '', :id => 'card_expiry', :class => "required cardExpiry", :placeholder => "MM / YY" %>
    </p>
    <p class="field" data-hook="card_code">
      <%= label_tag "card_code", Spree.t(:card_code) %><span class="required">*</span><br />
      <%= text_field_tag "card_code", '', options_hash.merge(:id => 'card_code', :class => 'required cardCode', :size => 5) %>
      <%= link_to "(#{Spree.t(:what_is_this)})", spree.content_path('cvv'), :target => '_blank', "data-hook" => "cvv_link", :id => "cvv_link" %>
    </p>
  </div>
  
  <%= f.submit Spree.t(:subscribe), class: 'continue btn btn-primary' %>
  <script>Spree.disableSaveOnClick();</script>
<% end %>

<script type="text/javascript" src="https://js.stripe.com/v2/"></script>
<script type="text/javascript">Stripe.setPublishableKey("<%= @plan.provider.preferred_public_key %>");</script>
<script>Spree.stripePaymentMethod = $('#plan_' + <%= @plan.id %> + '_subscribe')</script>
<%= javascript_include_tag "spree/frontend/stripe" %>